package com.flesler.stickjoy.controller
{
	public final class ControllerAxis extends BaseControllerComponent implements ControllerComponent
	{
		private var _position:Number = 0;
		
		public function ControllerAxis(key:String)
		{
			super(key);
		}
		
		// ControllerComponent Implementation
		
		public function get isAnalog():Boolean
		{
			return true;
		}
		
		public function get value():Object
		{
			return position;
		}
		
		// Raw position
		
		public function get position():Number
		{
			return _position;
		}
		
		public function set position(v:Number):void
		{
			if (v === position)
				return;
			
			_position = v;
			changed();
		}
		
		// Get position
		
		public function get isNegative():Boolean
		{
			return position < 0;
		}
		
		public function get isPositive():Boolean
		{
			return position > 0;
		}
		
		public function get isCentered():Boolean
		{
			return position === 0;
		}
		
		// Set position
		
		public function negative():void
		{
			position = -1;
		}
		
		public function positive():void
		{
			position = 1;
		}
		
		public function center():void
		{
			position = 0;
		}
		
	}
}